package org.pz.mq;

import lombok.extern.slf4j.Slf4j;
import org.pz.service.QuartzService;
import org.pz.vo.TaskVo;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class MqCustomer {

    @Autowired
    private QuartzService quartzService;

    @RabbitListener(queues = MqConfig.user_task_queue)
    public void c1(TaskVo taskVo, Message message) {
        try {
            quartzService.addCronJob(taskVo.getJobName(), taskVo.getCron(), taskVo.getCode());
        }catch (Exception e){
            log.info("创建定时任务失败！");
        }
    }
}
